$OpenBSD: patch-provider_libserver_ECSession_cpp,v 1.14 2015/04/05 22:25:08 robert Exp $
--- provider/libserver/ECSession.cpp.orig	Thu Mar  5 16:54:01 2015
+++ provider/libserver/ECSession.cpp	Fri Apr  3 23:11:10 2015
@@ -617,14 +617,22 @@ void ECSession::RemoveBusyState(pthread_t threadId)
 	i = m_mapBusyStates.find(threadId);
 
 	if(i != m_mapBusyStates.end()) {
+		// Since the specified thread is done now, record how much work it has done for us
+#if OPENBSD
+		struct tms end;
+
+		if(threadId) {
+			times(&end);
+			AddClocks((end.tms_utime / CLOCKS_PER_SEC) - timespec2dbl(i->second.threadstart), 0, GetTimeOfDay() - i->second.start);
+#else
 		clockid_t clock;
 		struct timespec end;
 
-		// Since the specified thread is done now, record how much work it has done for us
 		if(pthread_getcpuclockid(threadId, &clock) == 0) {
 			clock_gettime(clock, &end);
 
 			AddClocks(timespec2dbl(end) - timespec2dbl(i->second.threadstart), 0, GetTimeOfDay() - i->second.start);
+#endif
 		} else {
 			ASSERT(FALSE);
 		}
@@ -952,11 +960,20 @@ ECRESULT ECAuthSession::ValidateUserSocket(int socket,
 	uid_t uid;
 	char strbuf[1024];
 #ifdef SO_PEERCRED
+#ifndef __OpenBSD__
 	struct ucred cr;
+#else
+	struct sockpeercred cr;
+#endif
 	unsigned int cr_len;
 
+#ifndef __OpenBSD__
 	cr_len = sizeof(struct ucred);
 	if(getsockopt(socket, SOL_SOCKET, SO_PEERCRED, &cr, &cr_len) != 0 || cr_len != sizeof(struct ucred)) {
+#else
+	cr_len = sizeof(struct sockpeercred);
+	if(getsockopt(socket, SOL_SOCKET, SO_PEERCRED, &cr, &cr_len) != 0 || cr_len != sizeof(struct sockpeercred)) {
+#endif
 		er = ZARAFA_E_LOGON_FAILED;
 		goto exit;
 	}
